<html>
<head><meta charset="utf-8"><title>Fail to find macro definition under VSCode · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html">Fail to find macro definition under VSCode</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220358520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220358520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220358520">(Dec 18 2020 at 10:57)</a>:</h4>
<p>Hi, I'm using rust-analyzer in VSCode with Gtk, and I'm having problems with some macros. These show an error, "Fail to find macro definition", even if it's indeed on scope (with an use statement) and the code compiles fine. As a result, I don't get type hints or any of the niceties that r-a usually provides (only code highlighting).<br>
Is this a known problem? Is it a problem with my configuration?<br>
<a href="/user_uploads/4715/uoZZo-uVOsu60ryuyFDC5Z2J/Captura-de-pantalla-de-2020-12-18-11-57-33.png">Captura-de-pantalla-de-2020-12-18-11-57-33.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/uoZZo-uVOsu60ryuyFDC5Z2J/Captura-de-pantalla-de-2020-12-18-11-57-33.png" title="Captura-de-pantalla-de-2020-12-18-11-57-33.png"><img src="/user_uploads/4715/uoZZo-uVOsu60ryuyFDC5Z2J/Captura-de-pantalla-de-2020-12-18-11-57-33.png"></a></div>



<a name="220359224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220359224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220359224">(Dec 18 2020 at 11:05)</a>:</h4>
<p>Did type inference work before?</p>



<a name="220359422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220359422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220359422">(Dec 18 2020 at 11:07)</a>:</h4>
<p>Not for this same macro, AFAICT.<br>
For the rest of the file, there's no problem.</p>



<a name="220359508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220359508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220359508">(Dec 18 2020 at 11:08)</a>:</h4>
<p>It's probably not your configuration. <code>rust-analyzer</code> has a few bugs/limitations wrt. macros and that diagnostic was recently added and made them more visible. You can disable the warning if you want to, and you could also test in the nightly version since a couple of bugs were fixed this week.</p>



<a name="220359563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220359563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220359563">(Dec 18 2020 at 11:09)</a>:</h4>
<p>Ok, then I'll wait for next week's update. Thanks!</p>



<a name="220359574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220359574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220359574">(Dec 18 2020 at 11:09)</a>:</h4>
<p>A minimized test case (copy the <code>clone</code> definition to an empty project) would help if you want to file an issue.</p>



<a name="220359622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220359622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220359622">(Dec 18 2020 at 11:09)</a>:</h4>
<p>I'll have a look, then.</p>



<a name="220359823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220359823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220359823">(Dec 18 2020 at 11:11)</a>:</h4>
<p>It's this macro here: <a href="https://github.com/gtk-rs/glib/blob/f53054c8d392d22dba55ac122dddfe9fc9b191ef/src/clone.rs#L423">https://github.com/gtk-rs/glib/blob/f53054c8d392d22dba55ac122dddfe9fc9b191ef/src/clone.rs#L423</a> and it's indeed complex.</p>



<a name="220360009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220360009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220360009">(Dec 18 2020 at 11:13)</a>:</h4>
<p><a href="https://github.com/serde-rs/json/blob/master/src/macros.rs#L69">https://github.com/serde-rs/json/blob/master/src/macros.rs#L69</a> is similar and we found an issue in <a href="https://github.com/rust-analyzer/rust-analyzer/issues/6876">https://github.com/rust-analyzer/rust-analyzer/issues/6876</a>.</p>



<a name="220360318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220360318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220360318">(Dec 18 2020 at 11:17)</a>:</h4>
<p>That looks like the same problem. In fact, I don't remember having this problem, but I haven't touched this project for a long time so it may well be the case.<br>
Thanks for your help! It's a pleasure to use r-a!</p>



<a name="220360477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220360477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220360477">(Dec 18 2020 at 11:19)</a>:</h4>
<p>Hmm, this looks like it might be annoying to minimize</p>



<a name="220360570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220360570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220360570">(Dec 18 2020 at 11:20)</a>:</h4>
<p>I still get "Fail to find macro definition" in <a href="https://bpa.st/FKLQ">https://bpa.st/FKLQ</a></p>



<a name="220361382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220361382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220361382">(Dec 18 2020 at 11:31)</a>:</h4>
<p>Filed <a href="https://github.com/rust-analyzer/rust-analyzer/issues/6926">https://github.com/rust-analyzer/rust-analyzer/issues/6926</a></p>



<a name="220507074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220507074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220507074">(Dec 20 2020 at 07:09)</a>:</h4>
<p>@pachi <del>my</del> @Edwin Cheng's fix for that issue just landed, you could try a source build  to see if it's working. Unfortunately, I don't think it will be in tomorrow's release (but I might be wrong about that).</p>



<a name="220507406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220507406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220507406">(Dec 20 2020 at 07:20)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> wow, that's great! I 'm not sure I will be able to do the source build, but thanks for pointing and thanks to <span class="user-mention" data-user-id="216201">@Edwin Cheng</span> . If it gets into tomorrow release I'll report.</p>



<a name="220507803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220507803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220507803">(Dec 20 2020 at 07:35)</a>:</h4>
<p><del>Just clone and run <code>cargo xtask install</code> :-)</del></p>



<a name="220775877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Fail%20to%20find%20macro%20definition%20under%20VSCode/near/220775877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Fail.20to.20find.20macro.20definition.20under.20VSCode.html#220775877">(Dec 23 2020 at 10:10)</a>:</h4>
<p>I'm using this week's release and the fix is working fine. Thanks a lot!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>